- admin = local_assigns.fetch(:admin, false)
- ref = local_assigns.fetch(:ref, nil)
- commit_sha = local_assigns.fetch(:commit_sha, nil)
- retried = local_assigns.fetch(:retried, false)
- pipeline_link = local_assigns.fetch(:pipeline_link, false)
- stage = local_assigns.fetch(:stage, false)
- coverage = local_assigns.fetch(:coverage, false)
- allow_retry = local_assigns.fetch(:allow_retry, false)

%tr.build.commit{class: ('retried' if retried)}
  %td.status
    = render "ci/status/badge", status: build.detailed_status(current_user)

  %td.branch-commit
    - if can?(current_user, :read_build, build)
      = link_to namespace_project_build_url(build.project.namespace, build.project, build) do
        %span.build-link ##{build.id}
    - else
      %span.build-link ##{build.id}

    - if ref
      - if build.ref
        .icon-container
          = build.tag? ? icon('tag') : icon('code-fork')
        = link_to build.ref, namespace_project_commits_path(build.project.namespace, build.project, build.ref), class: "monospace branch-name"
      - else
        .light none
      .icon-container.commit-icon
        = custom_icon("icon_commit")

    - if commit_sha
      = link_to build.short_sha, namespace_project_commit_path(build.project.namespace, build.project, build.sha), class: "commit-id monospace"

    - if build.stuck?
      = icon('warning', class: 'text-warning has-tooltip', title: 'Build is stuck. Check runners.')

    - if retried
      = icon('refresh', class: 'text-warning has-tooltip', title: 'Build was retried')

    .label-container
      - if build.tags.any?
        - build.tags.each do |tag|
          %span.label.label-primary
            = tag
      - if build.try(:trigger_request)
        %span.label.label-info triggered
      - if build.try(:allow_failure)
        %span.label.label-danger allowed to fail
      - if build.manual?
        %span.label.label-info manual

  - if pipeline_link
    %td
      = link_to pipeline_path(build.pipeline) do
        %span.pipeline-id ##{build.pipeline.id}
      %span by
      - if build.pipeline.user
        = user_avatar(user: build.pipeline.user, size: 20)
      - else
        %span.monospace API

  - if admin
    %td
      - if build.project
        = link_to build.project.name_with_namespace, admin_namespace_project_path(build.project.namespace, build.project)
    %td
      - if build.try(:runner)
        = runner_link(build.runner)
      - else
        .light none

  - if stage
    %td
      = build.stage

  %td
    = build.name

  %td
    - if build.duration
      %p.duration
        = custom_icon("icon_timer")
        = duration_in_numbers(build.duration)

    - if build.finished_at
      %p.finished-at
        = icon("calendar")
        %span #{time_ago_with_tooltip(build.finished_at)}

  %td.coverage
    - if coverage && build.try(:coverage)
      #{build.coverage}%

  %td
    .pull-right
      - if can?(current_user, :read_build, build) && build.artifacts?
        = link_to download_namespace_project_build_artifacts_path(build.project.namespace, build.project, build), title: 'Download artifacts', class: 'btn btn-build' do
          = icon('download')
      - if can?(current_user, :update_build, build)
        - if build.active?
          = link_to cancel_namespace_project_build_path(build.project.namespace, build.project, build, return_to: request.original_url), method: :post, title: 'Cancel', class: 'btn btn-build' do
            = icon('remove', class: 'cred')
        - elsif allow_retry
          - if build.playable? && !admin
            = link_to play_namespace_project_build_path(build.project.namespace, build.project, build, return_to: request.original_url), method: :post, title: 'Play', class: 'btn btn-build' do
              = custom_icon('icon_play')
          - elsif build.retryable?
            = link_to retry_namespace_project_build_path(build.project.namespace, build.project, build, return_to: request.original_url), method: :post, title: 'Retry', class: 'btn btn-build' do
              = icon('repeat')
